class Solution(object):
    def lengthLongestPath(self, input):
        """
        :type input: str
        :rtype: int
        """
        class Node:
            def __init__(self, name):
                self.name = name
                self.xs = []
        levels = input.split('\n')
        path = []
        best = 0
        for level in levels:
            depth = level.count('\t')
            while len(path)<depth+1: path.append(0)
            while len(path)>depth+1: path.pop()
            path[depth]=len(level)-depth
            if level.count('.')!=0: best = max(best, sum(path)+len(path)-1)
        return best

print(Solution().lengthLongestPath("a.tar.gz"))